package com.example.zxw.db

import com.example.zxw.entity.ChannelEntity
import com.example.zxw.greendao.ChannelEntityDao
import com.example.zxw.greendao.GreenDaoManager

object ChannelDaoHelper {

    private val channelEntityDao: ChannelEntityDao = GreenDaoManager.daoSession.channelEntityDao

    /**
     * 获取所有频道列表
     */
    fun getChannelList(): List<ChannelEntity>? {
        return channelEntityDao.loadAll()
    }

    fun updateChannelList(list: List<ChannelEntity>): Boolean {
        try {
            channelEntityDao.deleteAll()
            list.forEach {
                channelEntityDao.insert(it)
            }
            return true
        } catch (e: Exception) {
            e.printStackTrace()
            return false
        }
    }


}